package com.byl.common.modules.service;

import com.byl.common.modules.dao.IDao;
import com.byl.sdk.bean.ResultBean;
import com.byl.sdk.utils.PageMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2019/7/24.
 */
@SuppressWarnings("ALL")
@Service
public abstract class BaseServiceImpl<T extends IDao> implements IService {

    @Autowired
    protected T baseDao;


    @Override
    public int save(Map map) {
        return baseDao.save(map);
    }

    @Override
    public int update(Map map) {
        return baseDao.update(map);
    }

    @Override
    public int delete(Serializable id) {
        return baseDao.delete(id);
    }

    @Override
    public ResultBean query(Map map) {
        PageMap pageMap = new PageMap(map);
        List list = baseDao.query(pageMap);
        int total = baseDao.queryCount(pageMap);
        return new ResultBean(pageMap.getPage(), pageMap.getPageSize(), total, list);
    }

    @Override
    public List list(Map map) {
        return baseDao.list(map);
    }

    @Override
    public Map getMapById(Serializable id) {
        return baseDao.getMapById(id);
    }

}
